<template>
  <div id="app">
    <router-view />
  </div>
</template>

<script>

export default {
  name: 'App',
  components: {

  },
  created () {
    // 跨标签页同步
    window.addEventListener('storage', (e) => {
      if (e.key === 'user_avatar') {
        this.$store.commit('user/SET_AVATAR', e.newValue)
      }
    })

    // 初始化时验证头像一致性
    const storedAvatar = localStorage.getItem('user_avatar')
    if (storedAvatar && storedAvatar !== this.$store.state.user.avatar) {
      this.$store.commit('user/SET_AVATAR', storedAvatar)
    }
  }
}
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>
